package com.aust.dynamicProxy.test3;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws Exception {
        System.out.println("真实对象");
        /**
         * 创建用户业务对象
         */
        UserServiceImpl userService = new UserServiceImpl();
        /**
         * 调用业务功能
         */
        userService.login("admin", "123456");
        System.out.println("--------------------------");

        userService.deleteUsers();
        System.out.println("--------------------------");

        String[] strings = userService.selectUsers();
        System.out.println("查询到的用户：" + Arrays.toString(strings));
        System.out.println("--------------------------");

        userService.test();
        System.out.println("--------------------------");

        userService.testInterface();
        System.out.println("--------------------------");

        System.out.println();
        System.out.println();
        System.out.println();

        System.out.println("代理对象");
        /**
         * 创建代理对象
         */
        UserService proxy = (UserService) ProxyUtil.createProxy(userService);
        /**
         * 代理对象调用业务功能
         */
        proxy.login("admin", "123456");
        System.out.println("--------------------------");

        proxy.deleteUsers();
        System.out.println("--------------------------");

        String[] s = proxy.selectUsers();
        System.out.println("查询到的用户：" + Arrays.toString(s));
        System.out.println("--------------------------");

        /**
         * 代理对象没有test()方法
         */

        proxy.testInterface();
        System.out.println("--------------------------");
    }
}
